cmake_minimum_required(VERSION 2.8)

project(w-webrtc-gateway)
add_compile_options(-std=c++11)

FILE (GLOB_RECURSE ALL_SOURCES
        "*.cpp" "*.c"
)

FILE (GLOB_RECURSE ALL_INCLUDES
    "*.h" "*.hpp"
)

function(IncludeSubDirRecursively rootDir)
    if (IS_DIRECTORY ${rootDir})
        include_directories(${rootDir})
    endif ()

    file(GLOB ALL_SUB RELATIVE ${rootDir} ${rootDir}/*)
    foreach (sub ${ALL_SUB})
        if (IS_DIRECTORY ${rootDir}/${sub})
            IncludeSubDirRecursively(${rootDir}/${sub})
        endif ()
    endforeach ()
endfunction()

IncludeSubDirRecursively(${CMAKE_CURRENT_SOURCE_DIR})
IncludeSubDirRecursively(${CMAKE_CURRENT_SOURCE_DIR}/../ThirdPartyInclude)

find_library(sslLib ssl HINTS ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdPartyLib)
find_library(cryptoLib crypto HINTS ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdPartyLib)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ThirdPartyLib)

add_executable(${PROJECT_NAME}
               ${ALL_SOURCES}
               ${ALL_INCLUDES}
)

target_link_libraries(${PROJECT_NAME}
                      pthread ${sslLib} ${cryptoLib} srtp2 pcrecpp pcreposix pcre
                      nice glib-2.0 gio-2.0 gmodule-2.0 gobject-2.0 gthread-2.0
)
